package com.hwd.srb.core.enmu;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@AllArgsConstructor
@Getter
public enum LendStatusEnum {

    CHECK(0, "待发布"),
    INVEST_RUN(1, "募资中"),
    PAY_RUN(2, "还款中"),
    PAY_OK(3, "已结清"),
    FINISH(4, "结标"),
    CANCEL(-1, "已撤标"),
//    OVERDUE(-1, "逾期催收中"),
//    BAD_BILL(-2, "坏账"),
    ;

    @EnumValue
    private Integer status;

    @JsonValue
    private String msg;


    @Override
    public String toString() {
        return this.msg;
    }

    public static String getMsgByStatus(int status) {
        LendStatusEnum[] arrObj = LendStatusEnum.values();
        return Arrays.stream(arrObj)
                .filter(obj -> status == obj.getStatus())
                .findFirst()
                .map(LendStatusEnum::getMsg)
                .orElse("");
    }
}
